﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using OrganizedIN.BAL;
using OrganizedIN.BussinessServices;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;

namespace OrganizedIN.UI.Media
{
    public partial class SearchMedia : System.Web.UI.Page
    {
        BLL objbll = new BLL();
        DateTime dt = DateTime.Now;
      

        protected void Page_Load(object sender, EventArgs e)
        {
            lblTodayDate.Text = String.Format("{0:D}", dt);

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string Sort = String.Empty;
            string strUserName = Session["UserID"].ToString();

            MyProfileMedia objMyMedia = new MyProfileMedia();
            objMyMedia.Media_Media_Name = txt_title.Text.Trim();
            objMyMedia.MediaSubscriptionDetail = txt_Subscription.Text.Trim();
            objMyMedia.MediaSharerName = txt_Share.Text.Trim();
            objMyMedia.MediaRating = ddl_rating.Text;
            objMyMedia.MediaOnlinePath = txt_type.Text.Trim();
            objMyMedia.Media_CreateDate = txt_date.Text.Trim();
            objMyMedia.MediaUserName = strUserName;
            if (ddl_Sort.Text != "Type (Offline or Online)" || ddl_Sort.Text != "Status")
            {
                if (ddl_Sort.Text == "Date Entered")
                {
                    Sort = "USER_MEDIA.CreatedDate";
                }
                else if (ddl_Sort.Text == "Title / Summary")
                {
                    Sort = "USER_MEDIA.Media_Name";
                }
                else if (ddl_Sort.Text == "Rating")
                {
                    Sort = "USER_MEDIA.Media_Rating";
                }
                
            }
            else
            {
                Sort = "USER_MEDIA.CreatedDate";
            
            }
            DataSet ds= objbll.MediaSearch(objMyMedia.Media_Media_Name, objMyMedia.MediaSubscriptionDetail, objMyMedia.MediaSharerName, objMyMedia.MediaRating, objMyMedia.Media_CreateDate, strUserName, objMyMedia.MediaOnlinePath, Sort);
            if (ds.Tables[0].Rows.Count > 0)
            {
                dgSearchResult.DataSource = ds.Tables[0];
                dgSearchResult.DataBind();
            }
            else
            {
                dgSearchResult.DataSource = null;
                dgSearchResult.DataBind();
            }
            
            
 
        }

        protected void dgSearchResult_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string _BTId = Convert.ToString(e.CommandArgument);
            string state = string.Empty;
            if (e.CommandName == "GORow")
            {

            }
        }

        protected void dgSearchResult_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

        }


    }
}

